﻿using BLL.MessageBoard;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication.MessageBoardHandle
{
    public partial class Handle : BaseHandle
    {
        private MessageBoardService messageBoardService = new MessageBoardService();
        public void Insert()
        {

            Utils.Model<Models.MessageBoard> modelUtils = new Utils.Model<Models.MessageBoard>();
            Models.MessageBoard messageBoard = modelUtils.GetModel(Request.Form);

            messageBoardService.Save(messageBoard);

            if (messageBoard.MessageBoardID != null)
            {
                Response.Write(JsonConvert.SerializeObject(new { code = 0, data = new { id = messageBoard.MessageBoardID }, msg = "留言成功" }));
            }
            else
            {
                Response.Write(JsonConvert.SerializeObject(new { code = -1, msg = "留言失败" }));
            }
        }
    }
}